# config/model_config.py

from .settings import settings

class ModelConfig:
    """模型配置类"""
    
    # 文本嵌入模型配置
    TEXT_EMBEDDING_MODEL = settings.EMBEDDING_MODEL
    TEXT_VECTOR_DIMENSION = settings.VECTOR_DIMENSION
    
    # 多模态嵌入模型配置
    MULTIMODAL_EMBEDDING_MODEL = settings.MULTIMODAL_EMBEDDING_MODEL
    IMAGE_VECTOR_DIMENSION = settings.IMAGE_VECTOR_DIMENSION
    
    # 大语言模型配置
    LLM_MODEL = settings.LLM_MODEL
    LLM_API_KEY = settings.LLM_API_KEY
    LLM_API_URL = settings.LLM_API_URL
    
    # 文本处理配置
    CHUNK_SIZE = settings.CHUNK_SIZE
    CHUNK_OVERLAP = settings.CHUNK_OVERLAP
    
    # RAG配置
    TOP_K = settings.TOP_K
    SIMILARITY_THRESHOLD = settings.SIMILARITY_THRESHOLD
    
    # 模型缓存配置
    MODEL_CACHE_DIR = "models/cache"
    MODEL_DOWNLOAD_TIMEOUT = 300  # 5分钟
    
    # 批处理配置
    BATCH_SIZE = 32
    MAX_CONCURRENT_REQUESTS = 10
    
    # 模型参数配置
    MODEL_PARAMS = {
        'text_embedding': {
            'normalize_embeddings': True,
            'show_progress_bar': False,
            'batch_size': 32,
        },
        'multimodal': {
            'normalize_embeddings': True,
            'show_progress_bar': False,
            'batch_size': 16,
        },
        'llm': {
            'temperature': 0.7,
            'max_tokens': 2048,
            'top_p': 0.9,
            'frequency_penalty': 0.0,
            'presence_penalty': 0.0,
        }
    }
    
    @classmethod
    def get_text_embedding_config(cls):
        """获取文本嵌入模型配置"""
        return {
            'model_name': cls.TEXT_EMBEDDING_MODEL,
            'vector_dimension': cls.TEXT_VECTOR_DIMENSION,
            'params': cls.MODEL_PARAMS['text_embedding']
        }
    
    @classmethod
    def get_multimodal_config(cls):
        """获取多模态模型配置"""
        return {
            'model_name': cls.MULTIMODAL_EMBEDDING_MODEL,
            'vector_dimension': cls.IMAGE_VECTOR_DIMENSION,
            'params': cls.MODEL_PARAMS['multimodal']
        }
    
    @classmethod
    def get_llm_config(cls):
        """获取大语言模型配置"""
        return {
            'model_name': cls.LLM_MODEL,
            'api_key': cls.LLM_API_KEY,
            'api_url': cls.LLM_API_URL,
            'params': cls.MODEL_PARAMS['llm']
        } 